﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data.Linq;

namespace Radar {
    public class RadarService : IRadarService {

        private string connString = @"Data Source=localhost;Initial Catalog=Radar;Integrated Security=true";

        public RadarService() { }

        public List<Capture> GetCaptures(DateTime startDate) {
            DataContext dc = new DataContext(connString);
            Table<Capture> tc = dc.GetTable<Capture>();
            var caps = dc.GetTable<Capture>().Where(c => c.date >= startDate);
            return new List<Capture>(caps.AsEnumerable());
        }

        public List<Image> GetImages(int[] captureId) {
            DataContext dc = new DataContext(connString);
            Table<Image> tc = dc.GetTable<Image>();
            var imgs = from c in dc.GetTable<Image>()
                    where captureId.AsQueryable().Contains(c.GetCaptureId())
                    select c;
            return new List<Image>(imgs);
        }

        public Dictionary<string, string> GetRadarParams() {
            throw new NotImplementedException();
        }
    }
}
